class Solution {
public:
    int minStoneSum(vector<int>& piles, int k) {
        priority_queue<int>q;
        for (auto x : piles) {
            q.push(x);
        }
        int ans = 0;
        while (k--) {
            int t = q.top();
            q.pop();
            t -= (t / 2);
            q.push(t);
        }
        while (q.size()) {
            ans += q.top();
            q.pop();
        }
        return ans;
    }
};